//
//  UserInfoPage.swift
//  Uber
//
//  Created by chen on 16/3/13.
//  Copyright © 2016年 chen. All rights reserved.
//

import UIKit

class UserInfoPage: FxBasePage,UIImagePickerControllerDelegate,UINavigationControllerDelegate {
    
    @IBOutlet weak var avatar:UIImageView!
    @IBOutlet weak var backUserView:UIView!
    @IBOutlet weak var firstName:UITextField!
    @IBOutlet weak var secondName:UITextField!
    @IBOutlet weak var avatarButton:UIButton!
    override func viewDidLoad() {
        super.viewDidLoad()
        backView.layer.masksToBounds = true
        backView.layer.cornerRadius = 5
        backUserView.layer.masksToBounds = true
        backUserView.layer.cornerRadius = 5
        self.title = "创建头像"
        setNavigationItem("Back.png", selector: "goBack", isRight: false)
        setNavigationItem("下一步", selector: "goRight", isRight: true)

        // Do any additional setup after loading the view.
    }
    override func goBack() {
        self.navigationController?.popToRootViewControllerAnimated(true)
    }
    override func goRight() {
        let page = AddPayPage()
        self.navigationController?.pushViewController(page, animated: true)
    }

    @IBAction func doSelectAvatar(sender:UIButton){
        let page = UIImagePickerController()
        //从本地图片库中取出图片
        page.sourceType = .PhotoLibrary
        //实现代理
        page.delegate = self
        self.presentViewController(page, animated: true, completion: nil)
    }
    //代理方法
    func imagePickerController(picker: UIImagePickerController, didFinishPickingImage image: UIImage, editingInfo: [String : AnyObject]?) {
        avatar.image = image
        avatarButton.titleLabel?.text = ""
        picker.dismissViewControllerAnimated(true, completion: nil)
    }

}
